import urllib.request


def proxy_user():

    url = "https://www.cnblogs.com/zrmw/p/9332801.html"

    # 添加代理
    proxy_ip_list = [
        {"http": "117.69.200.181:26266"},
        {"http": "183.164.238.68:9999"},
        {"http": "59.57.148.169:9999"},
        {"http": "223.241.79.20:8010"},
        {"http":"114.104.129.11:9999"},
    ]

    for proxy in proxy_ip_list:
        print(proxy)

        #利用遍历出来的ip创建处理器
        proxy_handler = urllib.request.ProxyHandler(proxy)

        # 创建opener
        opener = urllib.request.build_opener(proxy_handler)

        # 拿着代理ip去发送请求
        try:
            response = opener.open(url,timeout=1)
            print('ha')
        except Exception as e:
            print(e)




proxy_user()